home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Format CD 51
/
Amiga Format CD51 (2000-03-10)(Future Publishing)(GB)[!][issue 2000-04].iso
/
-in_the_mag-
/
program_perfection
/
vbcc
/
mystartup
/
minstart.s
< prev
next >
Wrap
Text File
|
2000-02-16
|
4KB
|
146 lines
*
* Minstart.s
*
* Fairly minimal startup code for VBCC
* See mystart.doc for details
*
* (C) Richard Drummond 1999
*
* Please feel free to use and abuse this code in your own
* programs, but don't blame me if it goes wrong . . .
*
* $Id :$
* $Log: minstart.s,v $
* Revision 1.2 2000/02/14 00:18:25 EvilRich
* Fixed Enforcer hit
*
* Revision 1.1.1.1 1999/11/10 22:38:28 richard
* Initial import to cvs
*
*
section "CODE",code
xref __main
xref _LVOOpenLibrary
xref _LVOCloseLibrary
xref _LVOWaitPort
xref _LVOGetMsg
xref _LVOForbid
xref _LVOReplyMsg
xref _LVOOpenLibrary
xref _LVOCloseLibrary
xref _LVOAlert
xdef __exit
xdef _SysBase
xdef _DOSBase
xdef _WBenchMsg
near a4,-2
initnear
move.l 4.w,_SysBase(a4) ; Set up SysBase
move.l a7,InitialSP(a4) ; Remember stack pointer
; This caused an Enforcer hit when started from WB - oops!
; We now check for WB startup first
; clr.b -1(a0,d0) ; Make sure argument string ends in NULL
; subq.l #1, d0 ; D0 is now the length of arg string
; move.l d0, -(a7) ; Shove pointer & length of arg string
; move.l a0, -(a7) ; on stack for passing to main()
move.l d0, d7 ; Temporarily store pointer and length
move.l a0, a3 ; of arg string
move.l _SysBase(a4), a6
move.l $114(A6),A0 ; Get pointer to our task from ExecBase
cmp.b #13,8(A0) ; Is it a process
bne skip ; Nope
tst.l $AC(A0) ; Is it a CLI ?
bne skip ; Nope
lea $5C(A0),A0 ; Find our message port
move.l a0, a3
jsr _LVOWaitPort(A6) ; Wait for WB message at port
move.l a3,a0
jsr _LVOGetMsg(A6) ; Get it
move.l d0,_WBenchMsg(a4) ; Store it
sub.l d0, d0
move.l d0, a0 ; Clear a0/d0
bra skip4
skip
move.l a3, a0 ; Restore ptr and len to a0/d0
move.l d7, d0
clr.b -1(a0,d0) ; Make sure argument string ends in NULL
subq.l #1, d0 ; D0 is now the length of arg string
skip4
move.l d0, -(a7) ; Shove pointer & length of arg string
move.l a0, -(a7) ; on stack for passing to main()
lea dosname(pc),a1
moveq.l #0, d0
jsr _LVOOpenLibrary(a6) ; open dos.library
move.l d0, _DOSBase(a4) ; store base address
bne ok
move.l #$38007,D7 ; failed to open DOS
jsr _LVOAlert(a6) ; so do Alert()
move.l #20, d2 ; Fatal Error
bra skip2
ok
jsr __main ; Call _main()
__exit
move.l d0, d2 ; Hold onto return code
move.l _SysBase(a4), a6
move.l _DOSBase(a4), a1
jsr _LVOCloseLibrary(a6) ; Close dos.library
skip2
move.l _WBenchMsg(a4),d3 ; Do we need to reply to WBMsg?
beq skip3 ; Nope
jsr _LVOForbid(a6) ; Yes
move.l d3,a1
jsr _LVOReplyMsg(a6) ; Reply
skip3
move.l d2 ,d0 ; Restore return code
move.l InitialSP(a4), a7; ; Restore stack pointer
rts
dosname
dc.b 'dos.library',0
section "__MERGED",data
InitialSP
dc.l 0
_SysBase
dc.l 0
_DOSBase
dc.l 0
_WBenchMsg
dc.l 0